<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>fof</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="fmwurlie.html" title="fmwurlie" />
    <link rel="next" href="fof2.html" title="fof2" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">fof</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="fmwurlie.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="fof2.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="fof"></a>
      <div class="titlepage"></div>
      <a id="IndexFof" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">fof</span>
        </h2>
        <p>fof — 
      Produces sinusoid bursts useful for formant and granular synthesis.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp110018224"></a>
        <h2>Description</h2>
        <p>
      Audio output is a succession of sinusoid bursts initiated at frequency <span class="emphasis"><em>xfund</em></span> with a spectral peak at <span class="emphasis"><em>xform</em></span>. For <span class="emphasis"><em>xfund</em></span> above 25 Hz these bursts produce a speech-like formant with spectral characteristics determined by the k-input parameters. For lower fundamentals this generator provides a special form of granular synthesis.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp110021312"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>fof</strong></span> xamp, xfund, xform, koct, kband, kris, kdur, kdec, iolaps, \
      ifna, ifnb, itotdur [, iphs] [, ifmode] [, iskip]</pre>
      </div>
      <div class="refsect1">
        <a id="idp110023744"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>iolaps</em></span> -- number of preallocated spaces needed to hold overlapping burst data. Overlaps are frequency dependent, and the space required depends on the maximum value of <span class="emphasis"><em>xfund * kdur</em></span>. Can be over-estimated at no computation cost. Uses less than 50 bytes of memory per <span class="emphasis"><em>iolap</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>ifna, ifnb</em></span> -- table numbers of two stored functions. The first is a sine table for sineburst synthesis (size of at least 4096 recommended). The second is a rise shape, used forwards and backwards to shape the sineburst rise and decay; this may be linear (<a class="link" href="GEN07.html" title="GEN07"><em class="citetitle">GEN07</em></a>) or perhaps a sigmoid (<a class="link" href="GEN19.html" title="GEN19"><em class="citetitle">GEN19</em></a>).
    </p>
        <p>
      <span class="emphasis"><em>itotdur</em></span> -- total time during which this <span class="emphasis"><em>fof</em></span> will be active. Normally set to p3. No new sineburst is created if it cannot complete its <span class="emphasis"><em>kdur</em></span> within the remaining <span class="emphasis"><em>itotdur</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>iphs</em></span> (optional, default=0) -- initial phase of the fundamental, expressed as a fraction of a cycle (0 to 1). The default value is 0.
    </p>
        <p>
      <span class="emphasis"><em>ifmode</em></span> (optional, default=0) -- formant frequency mode. If zero, each sineburst keeps the <span class="emphasis"><em>xform</em></span> frequency it was launched with. If non-zero, each is influenced by <span class="emphasis"><em>xform</em></span> continuously. The default value is 0.
    </p>
        <p>
      <span class="emphasis"><em>iskip</em></span> (optional, default=0) -- If non-zero, skip initialisation (allows legato use).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp110036160"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>xamp</em></span> -- peak amplitude of each sineburst, observed at the true end of its rise pattern. The rise may exceed this value given a large bandwidth (say, Q &lt; 10) and/or when the bursts are overlapping.
    </p>
        <p>
      <span class="emphasis"><em>xfund</em></span> -- the fundamental frequency (in Hertz) of the impulses that create new sinebursts.
    </p>
        <p>
      <span class="emphasis"><em>xform</em></span> -- the formant frequency, i.e. freq of the sinusoid burst induced by each <span class="emphasis"><em>xfund</em></span> impulse. This frequency can be fixed for each burst or can vary continuously (see <span class="emphasis"><em>ifmode</em></span>).
    </p>
        <p>
      <span class="emphasis"><em>koct</em></span> -- octaviation index, normally zero. If greater than zero, lowers the effective <span class="emphasis"><em>xfund</em></span> frequency by attenuating odd-numbered sinebursts. Whole numbers are full octaves, fractions transitional.
    </p>
        <p>
      <span class="emphasis"><em>kband</em></span> -- the formant bandwidth (at -6dB), expressed in Hz. The bandwidth determines the rate of exponential decay throughout the sineburst, before the enveloping described below is applied.
    </p>
        <p>
      <span class="emphasis"><em>kris, kdur, kdec</em></span> -- rise, overall duration, and decay times (in seconds) of the sinusoid burst. These values apply an enveloped duration to each burst, in similar fashion to a Csound <span class="emphasis"><em>linen</em></span> generator but with rise and decay shapes derived from the <span class="emphasis"><em>ifnb</em></span> input. <span class="emphasis"><em>kris</em></span> inversely determines the skirtwidth (at -40 dB) of the induced formant region. <span class="emphasis"><em>kdur</em></span> affects the density of sineburst overlaps, and thus the speed of computation. Typical values for vocal imitation are .003,.02,.007.
    </p>
        <p>
      Csound's <span class="emphasis"><em>fof</em></span> generator is loosely based on Michael Clarke's C-coding of IRCAM's <span class="emphasis"><em>CHANT</em></span> program (Xavier Rodet et al.). Each fof produces a single formant, and the output of four or more of these can be summed to produce a rich vocal imitation. <span class="emphasis"><em>fof</em></span> synthesis is a special form of granular synthesis, and this implementation aids transformation between vocal imitation and granular textures. Computation speed depends on <span class="emphasis"><em>kdur, xfund</em></span>, and the density of any overlaps.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp110049600"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the fof opcode. It uses the file <a class="ulink" href="examples/fof.csd" target="_top"><em class="citetitle">fof.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp110051456"></a>
          <p class="title">
            <strong>Example 306. Example of the fof opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o fof.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32  
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="oblock">instr</span> 1
  <span class="comment">; Combine five formants together to create </span>
  <span class="comment">; a transformation from an alto-"a" sound</span>
  <span class="comment">; to an alto-"i" sound.</span>
  <span class="comment">; Values common to all of the formants.</span>
  kfund <span class="opc">init</span> 261.659
  koct <span class="opc">init</span> 0
  kris <span class="opc">init</span> 0.003
  kdur <span class="opc">init</span> 0.02
  kdec <span class="opc">init</span> 0.007
  iolaps <span class="op">=</span> 100
  ifna <span class="op">=</span> 1
  ifnb <span class="op">=</span> 2
  itotdur <span class="op">=</span> p3

  <span class="comment">; First formant.</span>
  k1amp <span class="op">=</span> <span class="opc">ampdb</span>(0)
  k1form <span class="opc">line</span> 800, p3, 350
  k1band <span class="opc">line</span> 80, p3, 50

  <span class="comment">; Second formant.</span>
  k2amp <span class="opc">line</span> <span class="opc">ampdb</span>(<span class="op">-</span>4), p3, <span class="opc">ampdb</span>(<span class="op">-</span>20)
  k2form <span class="opc">line</span> 1150, p3, 1700
  k2band <span class="opc">line</span> 90, p3, 100

  <span class="comment">; Third formant.</span>
  k3amp <span class="opc">line</span> <span class="opc">ampdb</span>(<span class="op">-</span>20), p3, <span class="opc">ampdb</span>(<span class="op">-</span>30)
  k3form <span class="opc">line</span> 2800, p3, 2700
  k3band <span class="opc">init</span> 120

  <span class="comment">; Fourth formant.</span>
  k4amp <span class="opc">init</span> <span class="opc">ampdb</span>(<span class="op">-</span>36)
  k4form <span class="opc">line</span> 3500, p3, 3700
  k4band <span class="opc">line</span> 130, p3, 150

  <span class="comment">; Fifth formant.</span>
  k5amp <span class="opc">init</span> <span class="opc">ampdb</span>(<span class="op">-</span>60)
  k5form <span class="opc">init</span> 4950
  k5band <span class="opc">line</span> 140, p3, 200

  a1 <span class="opc">fof</span> k1amp, kfund, k1form, koct, k1band, kris, \
         kdur, kdec, iolaps, ifna, ifnb, itotdur
  a2 <span class="opc">fof</span> k2amp, kfund, k2form, koct, k2band, kris, \
         kdur, kdec, iolaps, ifna, ifnb, itotdur
  a3 <span class="opc">fof</span> k3amp, kfund, k3form, koct, k3band, kris, \
         kdur, kdec, iolaps, ifna, ifnb, itotdur
  a4 <span class="opc">fof</span> k4amp, kfund, k4form, koct, k4band, kris, \
         kdur, kdec, iolaps, ifna, ifnb, itotdur
  a5 <span class="opc">fof</span> k5amp, kfund, k5form, koct, k5band, kris, \
         kdur, kdec, iolaps, ifna, ifnb, itotdur

  <span class="comment">; Combine all of the formants together</span>
asig <span class="opc">sum</span> (a1<span class="op">+</span>a2<span class="op">+</span>a3<span class="op">+</span>a4<span class="op">+</span>a5) <span class="op">*</span> 13000
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; sine wave</span>
<span class="stamnt">f</span> 1 0 4096 10 1
<span class="comment">; sigmoid wave</span>
<span class="stamnt">f</span> 2 0 1024 19 0.5 0.5 270 0.5

<span class="stamnt">i</span> 1 0 1
<span class="stamnt">i</span> 1 2 5	<span class="comment">; same but slower</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />

      The formant values for the alto-"a" sound were taken from the <a class="link" href="MiscFormants.html" title="Appendix D. Formant Values"><em class="citetitle">Formant Values Appendix</em></a>.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp110056896"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="fof2.html" title="fof2"><em class="citetitle">fof2</em></a>, 
      <a class="link" href="MiscFormants.html" title="Appendix D. Formant Values"><em class="citetitle">Formant Values Appendix</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp110059968"></a>
        <h2>Credits</h2>
        <p>Added in version 1 (1990)</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="fmwurlie.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="fof2.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">fmwurlie </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> fof2</td>
        </tr>
      </table>
    </div>
  </body>
</html>
